//
//  DelayedBinding.h
//  sad
//
//  Created by Christopher Kemsley on 2/7/12.
//  Copyright (c) 2012 iAppolopolis. All rights reserved.
//

#ifndef sad_DelayedBinding_h
#define sad_DelayedBinding_h

#include <vector>

NamespaceBegin




class	DelayedBinding
{
public:
	static void	runAll ()
		{
		std::vector<DelayedBinding*>::iterator	here	=	queue().begin() ;
		std::vector<DelayedBinding*>::iterator	end		=	queue().end() ;
		while ( here != end )
			{
			DelayedBinding * worker = *(here++) ;
			worker -> bind () ;
			delete worker ;
			}
		queue().clear() ;
		}
	
	
protected:
	
	DelayedBinding ()
		{
		queue() . push_back ( this ) ;
		}
	virtual ~DelayedBinding ()
		{
		
		}
	
	virtual void	bind () = 0 ;
	
	
private:
	static std::vector<DelayedBinding*>&	queue ()
		{
		static std::vector<DelayedBinding*> q ;
		return q ;
		}
} ;




NamespaceEnd

#endif
